package com.csxh.eshop.dao.jdbc;

import static org.junit.Assert.assertTrue;

import org.junit.Test;

import com.csxh.eshop.bean.Category;
import com.csxh.eshop.bean.Product;
import com.csxh.eshop.dao.CategoryDao;
import com.csxh.eshop.dao.Dao;
import com.csxh.eshop.dao.ProductDao;
import com.csxh.util.Pager;

public class JdbcDaoImplTest {

	@Test
	public void test() {

		
		Dao dao = new CategoryDao();

		Category category = new Category();

		category.setId(4);
		category.setBigImg("bigImg");
		category.setDescript("xxxx");
		category.setName("MP3");
		category.setSmallImg("smallImg");
		category.setUiStyle("yyyyy");

		Category c = (Category) dao.findById(4);
		System.out.println(c);
		// assertTrue(b);

	}

	@Test
	public void test2() {

		ProductDao dao = new ProductDao();

		Pager<Product> productPager = dao.findPager(1, 5, "price>?", 10);

		System.out.println(productPager.getTotal());
		System.out.println(productPager.getDataList());

		assertTrue(!productPager.isEmpty());

	}

	@Test
	public void test3() {
		
		Class<?> clazz=Category.class;
		Dao<Object> dao = new JdbcDaoImpl<Object>(clazz) {
			
		};
		
		Pager<Object> productPager = dao.findPager(1, 5, "");

		System.out.println(productPager.getTotal());
		System.out.println(productPager.getDataList());

		System.out.println(productPager.getFieldInfoList());
		
		assertTrue(!productPager.isEmpty());
		
	}

}
